<?php

    if(empty($_POST['moduleName'])){
        skip("$_SERVER[REQUEST_URI]",'error','板块名称不能为空！');
    }
    if(mb_strlen($_POST['moduleName'],'utf-8')>40){
        skip("$_SERVER[REQUEST_URI]",'error','板块名称不能超过40个字符！');
    }
    if(!is_numeric($_POST['sort'])){
        skip("$_SERVER[REQUEST_URI]",'error','排序内容只能为数字！');
    }
    if(isset($_POST['referid']))
        if(!is_numeric($_POST['referid'])||$_POST['referid']==0){
            skip("$_SERVER[REQUEST_URI]",'error','未选择版主！');
        }
    $_POST=tosqlstring($link,$_POST);
    switch($cheekflag){
        case 'add':
            $query="select *from fatherModule where moduleName='{$_POST['moduleName']}'";
            break;
        case 'update':
            $query="select *from fatherModule where moduleName='{$_POST['moduleName']}' and id!={$_GET['id']}";
            break;
        case 'cm_add':
            $query="select *from fatherModule where moduleName='{$_POST['moduleName']}'";
            break;  
        case 'cm_update':
            $query="select *from childModule where moduleName='{$_POST['moduleName']}' and id!={$_GET['id']}";
            break;
    }
   
    $result=execute($link,$query);
    if(mysqli_num_rows($result)){
        skip("$_SERVER[REQUEST_URI]",'error','该板块已存在！');
    }
    ?>